package member1;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JLabel;
import java.awt.FlowLayout;

public class member extends JFrame {

	private JPanel contentPane;
	private JMenuBar menuBar;
	private JMenu menu;
	private JMenuItem mntmNewMenuItem;
	private JMenuItem mntmNewMenuItem_1;
	private Data6[] data = new Data6[10];
	private JMenuItem mntmNewMenuItem_2;
	private JMenuItem mntmNewMenuItem_3;
	private JLabel label;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					member frame = new member();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public member() {
		
		//data[0] = new Data6 ("인지", "서울", "333-111", "inji@naver.com", 23);
		//data[1] = new Data6 ("호야", "청주", "213-111", "inji@naver.com", 24);
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 497, 397);
		setJMenuBar(getMenuBar_1());
		contentPane = new JPanel();
		contentPane.setBackground(new Color(51, 153, 204));
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BorderLayout(0, 0));
		contentPane.add(getLabel(), BorderLayout.CENTER);
		
		
	}

	private JMenuBar getMenuBar_1() {
		if (menuBar == null) {
			menuBar = new JMenuBar();
			menuBar.add(getMenu());
		}
		return menuBar;
	}
	private JMenu getMenu() {
		if (menu == null) {
			menu = new JMenu("회원 관리");
			menu.setFont(new Font("맑은 고딕", Font.PLAIN, 11));
			menu.add(getMntmNewMenuItem());
			menu.add(getMntmNewMenuItem_1());
			menu.add(getMntmNewMenuItem_2());
			menu.add(getMntmNewMenuItem_3());
		}
		return menu;
	}
	private JMenuItem getMntmNewMenuItem() {
		if (mntmNewMenuItem == null) {
			mntmNewMenuItem = new JMenuItem("입력");
			mntmNewMenuItem.setFont(new Font("맑은 고딕", Font.PLAIN, 11));
			mntmNewMenuItem.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					// 입력 메뉴가 클릭되면 처리되어야 할 부분 
					System.out.println("insert");
					Input panel = new Input(); 
					panel.setD(data);
					contentPane.removeAll();
					contentPane.add(panel);
					contentPane.updateUI();
		
				}
			});
		}
		return mntmNewMenuItem;
	}
	private JMenuItem getMntmNewMenuItem_1() {
		if (mntmNewMenuItem_1 == null) {
			mntmNewMenuItem_1 = new JMenuItem("출력");
			mntmNewMenuItem_1.setFont(new Font("맑은 고딕", Font.PLAIN, 11));
			mntmNewMenuItem_1.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					// 출력 메뉴가 클릭되면 처리되어야 할 부분 
					System.out.println("output");
					
					Output panel = new Output(); 
					panel.setD(data);
					
					contentPane.removeAll();
					contentPane.add(panel);
					contentPane.updateUI();
					
					
					
					
					
				}
			});
		}
		return mntmNewMenuItem_1;
	}
	
	
	private JMenuItem getMntmNewMenuItem_2() {
		if (mntmNewMenuItem_2 == null) {
			mntmNewMenuItem_2 = new JMenuItem("수정");
			mntmNewMenuItem_2.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					System.out.println("수정");
					Modify panel = new Modify();
					
					panel.setD(data);
					
					contentPane.removeAll();
					contentPane.add(panel);
					contentPane.updateUI();
				}
			});
			mntmNewMenuItem_2.setFont(new Font("맑은 고딕", Font.PLAIN, 11));
		}
		return mntmNewMenuItem_2;
	}
	private JMenuItem getMntmNewMenuItem_3() {
		if (mntmNewMenuItem_3 == null) {
			mntmNewMenuItem_3 = new JMenuItem("삭제");
			mntmNewMenuItem_3.setFont(new Font("맑은 고딕", Font.PLAIN, 11));
			mntmNewMenuItem_3.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					System.out.println("삭제");
					
					Delete panel = new Delete();
					
					panel.setD(data);
					
					contentPane.removeAll();
					contentPane.add(panel);
					contentPane.updateUI();
					
				}
			});
		}
		return mntmNewMenuItem_3;
	}
	private JLabel getLabel() {
		if (label == null) {
			label = new JLabel("         Data management Program\r\n@ 1조");
			label.setForeground(Color.WHITE);
			label.setBackground(new Color(0, 153, 204));
			label.setOpaque(true);
			label.setFont(new Font("나눔손글씨 펜", Font.PLAIN, 30));
		}
		return label;
	}
}
